import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smttable/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getTrackList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smttable/track/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getTrackSheetList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smttable/feeding-track-sheet-page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getTrackDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/track/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/smttable/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const removeTrack = (ids) => {
  return request({
    url: '/api/mes-product/smttable/track/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const addTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const updateTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

/**
 * 验证机台编码、产品编码
 */
export const verifyMachineCodeOrPartNo = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/check-table-machine-code-part-no',
    method: 'post',
    data: row
  });
};

/**
 * 获取已选中的产品数据
 */
export const getSelectedProduct = (array) => {
  return request({
    url: '/api/mes-admin/partmaster/list-part-master',
    method: 'post',
    data: array
  });
};
